package com.meta.rule;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RuleRunContext {	
	private Map<String,Object> values = new HashMap<String,Object>();
	private boolean valid = true;
	private List<String> messages = new ArrayList<String>();
	private boolean success = true;
	
	public RuleRunContext() {
	}

	
	public Object getValue(String key) {
		
		return values.get(key);
	}
	
	public void putValue (String key, Object value ) {
		
		values.put(key, value);
	}

	public Map<String, Object> getValues() {
		return values;
	}

	public void setValues(Map<String, Object> values) {
		this.values = values;
	}

	public boolean isValid() {
		return valid;
	}

	public void setValid(boolean valid) {
		this.valid = valid;
	}

	public List<String> getMessages() {
		return messages;
	}

	public void setMessages(List<String> messages) {
		this.messages = messages;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}
	
	public String getMessageText() {
		
		StringBuffer buffer = new StringBuffer(); 
		for ( String message : messages ) {
			
			buffer.append(message);
			
		}		
		return buffer.toString();
	}
	
	public void addMessage( String message ) {
		
		this.messages.add(message);
		
	}

}
